/*
 * Copyright 2020 edenrun.cn All right reserved. This software is the
 * confidential and proprietary information ofedenrun.cn ("Confidential
 * Information"). You shall not disclose such Confidential Information and shall
 * use it only in accordance with the terms of the license agreement you entered
 * into with edenrun.cn.
 */

package com.zoom.pluto.zxg.model.enums;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;

/**
 * 错误码枚举类
 *
 * @author zoom
 * @date 2020-06-07
 */
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public enum ErrorCode {

    /**
     * 系统异常
     */
    SYSTEM_ERROR("1000", "处理失败"),
    /**
     * 业务异常
     */
    BUSINESS_ERROR("2000", "业务异常"),
    /**
     * 未授权请求
     */
    AUTH_ERROR("3000", "未授权请求"),
    /**
     * 非法参数
     */
    INVALID_PARAM("4000", "非法参数"),

    /**
     * 未知异常
     */
    UNKNOWN("5000", "未知异常"),

    /**
     * 数据重复
     */
    DUPLICATE_KEY("6000", "数据重复"),
    ;

    /**
     * 错误码
     */
    String code;

    /**
     * 错误信息
     */
    String errorMsg;

    public static ErrorCode getErrorCode(String errorCode) {
        for(ErrorCode ec : ErrorCode.values()) {
            if(ec.getErrorCode().equals(errorCode)) {
                return ec;
            }
        }
        return ErrorCode.UNKNOWN;
    }

    public String getErrorCode() {
        return code;
    }
}
